/*
 * This class is not used in this version. However it will be in the next versions to come.
 */

package com.meraklisina.latex ;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;

public class LatexButton extends JButton
{
    String name = "" ;

    String type = "" ;

    String latexCommand = "" ;

    String tooltip = "" ;

    String prefix = "" ;

    String postfix = "" ;

    String icon = "" ;

    public void LatexButton( )
    {

    }

    public void LatexButton( String name, String type, String latexCommand, String tooltip, String prefix, String postfix, String icon )
    {
        this.name = name ;
        this.type = type ;
        this.latexCommand = latexCommand ;
        this.tooltip = tooltip ;
        this.prefix = prefix ;
        this.postfix = postfix ;
        this.icon = icon ;
        // setText(name);
        //setToolTipText(tooltip);
    }

    public void applyAll( )
    {
        //setIcon(icon); // NOI18N
        this.setText( this.name ) ; // NOI18N
        this.setToolTipText( this.tooltip ) ; // NOI18N
        this.setFocusable( false ) ;
        this.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER ) ;
        this.setName( this.name ) ; // NOI18N
        this.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM ) ;
    }

    public String getIconString( )
    {
        return this.icon ;
    }

    public void setIconString( String iconPath )
    {
        this.icon = iconPath ;
        Icon imageIcon = new ImageIcon( this.icon ) ;
        if( this.icon != null )
        {
            super.setIcon( imageIcon ) ;
        }
    }

    public String getLatexCommand( )
    {
        return this.latexCommand ;
    }

    public void setLatexCommand( String latexCommand )
    {
        this.latexCommand = latexCommand ;
    }

    public String getPrefix( )
    {
        return this.prefix ;
    }

    public void setPrefix( String prefix )
    {
        this.prefix = prefix ;
    }

    public String getType( )
    {
        return this.type ;
    }

    public void setType( String type )
    {
        this.type = type ;
    }

    public String getPostfix( )
    {
        return this.postfix ;
    }

    public void setPostfix( String postfix )
    {
        this.postfix = postfix ;
    }

    public String getTooltip( )
    {
        return this.tooltip ;
    }

    public void setTooltip( String tooltip )
    {
        this.tooltip = tooltip ;
        super.setToolTipText( tooltip ) ;
    }

    @Override
    public String getText( )
    {
        return this.name ;
    }

    @Override
    public void setText( String name )
    {
        //this.name = name;
        //super.setText(name);
        if( this.icon != null )
        {
            this.name = name ;
            super.setName( name ) ;
        }
    }

    @Override
    public String toString( )
    {
        String s = "Name: " + this.name + "; Type: " + this.type + "; Latex Command: " + this.latexCommand + "; Tooltip: " + this.tooltip + "; Prefix: " + this.prefix + "; Postfix: " + this.postfix + "; Icon: " + this.icon + "." ;
        return s ;
    }
}
